package todo;

import se.lth.cs.realtime.*;
import se.lth.cs.realtime.event.*;
import done.*;

public class WashingController implements ButtonListener {
	private AbstractWashingMachine mach;
	private double speed;
	private TemperatureController tempc;
	private WaterController waterc;
	private SpinController spinc;
    
    public WashingController(AbstractWashingMachine theMachine, double theSpeed) {
    	mach = theMachine;
    	speed = theSpeed;
    	Sim.speed = speed;
    	
    	waterc = new WaterController(mach);
    	tempc = new TemperatureController(mach);
    	spinc = new SpinController(mach);

    	waterc.start();
    	tempc.start();
    	spinc.start();
    }

    public void processButton(int theButton) {
    	System.out.println("button: "+theButton);
    	WashingProgram p = null;
    	switch (theButton) {
    	case 0:
    	case 1:
    		p = new WashingProgram1(mach, speed, tempc, waterc, spinc);
    		break;
    	case 2:
    		p = new WashingProgram2(mach, speed, tempc, waterc, spinc);
    		break;
    	case 3:
    		p = new WashingProgram3(mach, speed, tempc, waterc, spinc);    		
    	}
   		p.start();
    }
}
